package com.atcd.springboot2.controller;


import com.atcd.springboot2.bean.Student;
import com.atcd.springboot2.bean.User;
import org.springframework.core.io.FileSystemResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

@Controller
public class ResponseJsonController {


    //给前端返回一个json数据
    @ResponseBody
    @GetMapping("/getJsonUser")
    public User testJson(){
        return  new User("唐玮","123",new Student(222,"bb"));
    }

    //相应一个图片
    @ResponseBody
    @GetMapping("/imgRes")
    public BufferedImage getImage() throws Exception {
        return ImageIO.read(new FileInputStream(new File("D:/222.jpg")));
    }
}
